package com.taotao.controller;

import com.taotao.pojo.ItemCat;
import com.taotao.service.ItemCatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


@Controller
@RequestMapping(value = "item/cat")
public class ItemCatController {

    @Autowired
    private ItemCatService itemCatService;

    /**
     * 1、完成查询商品类目的功能 1.1 确定需要的数据格式 2、配置路径，限制方法 3、设置参数 4、响应内容
     */
    @RequestMapping(value = "list")
    @ResponseBody
    public List<ItemCat> queryItemCatByParentId(@RequestParam(value = "id", defaultValue = "0") Long parentId) {
        List<ItemCat> itemCats = itemCatService.queryItemListByParentId(parentId);
        return itemCats;
    }
}
